package org.fujay.commons.langchain4j.config;

import dev.langchain4j.store.memory.chat.ChatMemoryStore;
import dev.langchain4j.store.memory.chat.InMemoryChatMemoryStore;
import org.fujay.commons.langchain4j.core.factory.ModelFactory;
import org.fujay.commons.langchain4j.core.model.ModelProvider;
import org.fujay.commons.langchain4j.core.model.impl.LocalAiModelProvider;
import org.fujay.commons.langchain4j.core.model.impl.OllamaModelProvider;
import org.fujay.commons.langchain4j.core.model.impl.OpenAiModelProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

import java.util.List;

/**
 * @author slm
 * @description
 */
@AutoConfiguration
public class ModelConfig {

    @Bean
    public OllamaModelProvider ollamaModelProvider() {
        return new OllamaModelProvider();
    }

    @Bean
    public OpenAiModelProvider openAiModelProvider() {
        return new OpenAiModelProvider();
    }

    @Bean
    public LocalAiModelProvider localAiModelProvider() {
        return new LocalAiModelProvider();
    }

    @Bean
    public ModelFactory modelFactory(List<ModelProvider> providers) {
        return new ModelFactory(providers);
    }

    @Bean
    @ConditionalOnMissingBean
    public ChatMemoryStore chatMemoryStore() {
        return new InMemoryChatMemoryStore();
    }
}
